package weaver.interfaces.holyview.duss.action;

import com.alibaba.fastjson.JSONObject;
import com.weaver.general.BaseBean;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.holyview.duss.util.DataUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-10-23
 * @Description: 公告发布流程
 * @ModifyLog:
 **/
/*
 *@Description: 借款流程提交后调用付款单保存接口
 *@Param:
 *@return:
 *@Author: Dusongsong
 *@Date: 2020/12/10
 */
public class WeaLoanAction extends BaseBean implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        RecordSet rs = new RecordSet();
        BaseBean baseBean = new BaseBean();
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        int userid = requestInfo.getRequestManager().getUserId();
        String method = "Save";
        baseBean.writeLog( "------WeaLoanAction-------"+requestid );
        JSONObject jsonData = new JSONObject();
        String sql = "select scdjlx,zfrq,jdrybm,jsfs,fkyt,jkje,zfzh from "+tablename+" where requestid=?";
        rs.executeQuery( sql,requestid );
        rs.next();
        String scdjlx = Util.null2String( rs.getString( "scdjlx" ) );
        jsonData.put("rq",Util.null2String(rs.getString( "zfrq" )));
        jsonData.put("jdrybm",Util.null2String(rs.getString( "jdrybm" )));
        jsonData.put("je",Util.null2String(rs.getString( "jkje" )));
        jsonData.put("zfzh",getYhzhlb(Util.null2String(rs.getString( "zfzh" ))));
        baseBean.writeLog("jsonData=",jsonData.toJSONString());

        try {
            String result = "";
            if("0".equals(scdjlx)){
                result =  DataUtil.otherBusinessReceipt(jsonData);
            }
            if("1".equals(scdjlx)){
                result =  DataUtil.procurementBusinessReceipt(jsonData);
            }
            if("2".equals(scdjlx)){
                result =  DataUtil.passCertificate(jsonData);
            }
            DataUtil.saveCallInterLog("付款单",method,result,requestid,userid);
            baseBean.writeLog("result="+result.toString());
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            writeLog( "异常参考:" + e );
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "Action接口异常！" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }

   public static String getYhzhlb(String id){
        RecordSet rs = new RecordSet(  );
        rs.executeQuery("select zhmc from uf_yhzhlb where id = ?",id);
        rs.next();
        String zhmc = Util.null2String(rs.getString( "zhmc" ));
        return zhmc;
   }

    public static void main(String[] args) {
        System.out.println(Util.getFloatValue(""));
    }
}
